package edu.ccut.saturn.basecomponent.databasecomponent;

import java.util.ArrayList;
import java.util.List;

import edu.ccut.saturn.basecomponent.database.util.ConditionUtils;
import edu.ccut.saturn.basecomponent.database.util.SQLExecute;
import edu.ccut.saturn.component.DefaultComponent;
import edu.ccut.saturn.component.IParameter;
import edu.ccut.saturn.component.IParameterContext;
import edu.ccut.saturn.component.SaturnData;

public class QueryByConditionWithPageExt2Component extends DefaultComponent {
	/**
	 * 
	 */
	private static final long serialVersionUID = 7300756504360092298L;

	@SuppressWarnings("deprecation")
	@Override
	public void execute(IParameterContext parameterContext) throws Exception {
		//拼条件
		List<String> conditions = new ArrayList<String>();
		List<IParameter> list = parameterContext.getParameters();
		for(int i=6;i<list.size();i++){
			IParameter parameter = list.get(i);
			Object arg = parameter.getValue();
			String expression = (String) arg;
			conditions.add(expression);
		}
		String whereCondition = ConditionUtils.getConditionWithPremiss(conditions,parameterContext);
		//分页查询
		List<SaturnData> result = SQLExecute.queryByConditionWithPage(whereCondition,parameterContext);
    	//设置返回值
    	parameterContext.setParameter(4, result);
	}
}